package cn.jiangjiesheng.bootstrap.commons.utils;

import cn.jiangjiesheng.bootstrap.commons.exception.BizzException;
import com.google.common.base.Strings;
import org.apache.commons.collections4.CollectionUtils;

import java.util.Collection;

/**
 * Created by dev@jiangjiesheng.cn on 19-11-11.
 */
public class AssertUtils {

    public static void notNull(Object object, String message) {
        if (object == null) {
            throw new BizzException(message);
        }
    }

    public static void notNullOrEmpty(String str, String message) {
        if (Strings.isNullOrEmpty(str)) {
            throw new BizzException(message);
        }
    }

    public static void isTrue(boolean expression, String message) {
        if (!expression) {
            throw new BizzException(message);
        }
    }

    public static void isFalse(boolean expression, String message) {
        if (expression) {
            throw new BizzException(message);
        }
    }

    public static void notEmpty(Collection<?> collection, String message) {
        if (CollectionUtils.isEmpty(collection)) {
            throw new BizzException(message);
        }
    }

}
